import axios from '@/request.js'
import { queryParams } from "@/composables/util"




export function getproduct(page,query){
    let r = queryParams(query)
    return axios.get(`/product?page=${page}${r}`);
  } 

export function create(data) {
    return axios.post("/product/create", data);
  }

export function update(id,data) {
  return axios.post(`/product/update?id=${id}`, data);
}

export function del(id){
  return axios.post(`/product/delete/id/${id}`);
}

export function show(id){
  return axios.get(`/product/show/id/${id}`);
}

//添加規格

export function specs(data){
  return axios.post("/specs/create", data);
}
//修改規格
export function updatespecs(id,data) {
  return axios.post(`/specs/update?id=${id}`, data);
}

//删除规格
export function delspecs(id){
  return axios.post(`/specs/delete/id/${id}`);
}

//添加规格值
export function createvalue(data){
  return axios.post("/specsvalue/create", data);
}

//刪除规格值
export function delvalue(id){
  return axios.post(`/specsvalue/delete/id/${id}`);
}



//數據分析
export function getsale(page,query){
  let r = queryParams(query)
  return axios.get(`/sale?page=${page}${r}`);
}

export function delsale(id){
  return axios.post(`/sale/delete/id/${id}`);
}

export function getexcel(){
  return axios.get(`/sale/excel`);
}


export function round(keyword='',time=[]) {
  
  return axios.get(`/sale/round?keyword=${keyword}&time=${time}`);
}
//圖形分析
export function dowexc(sale) {
  
  return axios.get(`/sale/dowexc/?sale=${sale}`);
}

export function dowpdf(sale) {
  
  return axios.get(`/sale/dowpdf/?sale=${sale}`);
}
